import collections


class Solution(object):
    def increasingTriplet(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        n = len(nums)
        stack = []
        index = 0
        while index < n and len(stack) < 3:
            if not stack:
                stack.append(nums[index])
            else:
                if nums[index] > stack[-1]:
                    stack.append(nums[index])
                else:
                    for i in range(len(stack)):
                        if stack[i] >= nums[index]:
                            stack[i] = nums[index]
                            break
            index += 1
        if len(stack) == 3:
            return True
        else:
            return False


data = Solution()
nums = [2, 1, 5, 0, 4, 6]
print(data.increasingTriplet(nums))
